import axios from "./axios";
import { header1,header2 } from "./common";
import {api} from '../api/index'
function getProductList( ) {

    return  axios({
        method:'get',
        url:api.product.product_List,
        headers:{
           ...header1
        },
        // params:{
        //     limit:pageSize,
        //     skip:(pageNo-1)*pageSize
        // }
    })
}
function getProduct(ObjectId:string){
    return axios({
        method:'get',
        url:api.product.product_ById+"/"+ObjectId,
        headers:{
            ...header2
        }
    })
}
function delProduct(objectId:string){
    return axios({
        method:'delete',
        url:api.product.product_Del+"/"+objectId,
        headers:{
            ...header2
        }
    })
}
function addProduct(no:string,productId:string,productName:string,productPlan:string){
    return axios({
        method:'post',
        url:api.product.product_Add,
        headers:{
            ...header1
        },
        data:{
            no,productId,productName,productPlan
        }
    })
}

function updateProduct(no:string,productId:string,productName:string,productPlan:string,objectId:string) {
    return axios({
        method:'put',
        url:api.product.product_Update+"/"+objectId,
        headers:{
            ...header2
        },
        data:{
            "no":no,
            "productId":productId,
            "productName":productName,
            "productPlan":productPlan
        }
    })
}
export {
    getProductList,
    getProduct,
    delProduct,
    addProduct,
    updateProduct
}